<template>
  <view>
    <Item :list="list"></Item>
  </view>
</template>
<script>
import data from "./data.json";
import Item from "./Item.vue";
import uniNavBar from "@/components/uni-nav-bar/uni-nav-bar.vue";
export default {
  components: { uniNavBar, Item },
  onLoad: function (option) {
    if (option.type) {
      let list = data.filter((item) => item.type === option.type);
      this.list = list;
      uni.setStorageSync("list", JSON.stringify(this.list));
    }else{
      let list = JSON.parse(uni.getStorageSync("list"));
      this.list = list;
    }
  },
  components: { Item },
  data() {
    return {
      list: [],
    };
  },
  methods: {
    goback() {
      uni.switchTab({
        url: `../index/index`,
      });
    },
  },
};
</script>
<style lang="scss" scoped>
</style>